/// 用户数据模型
class UserEssence {
  final String id;
  final String account;
  final String password;
  final String username;
  final String signature;
  final String avatar;

  UserEssence({
    required this.id,
    required this.account,
    required this.password,
    required this.username,
    required this.signature,
    required this.avatar,
  });

  /// 从Map创建UserEssence
  factory UserEssence.fromMap(Map<String, dynamic> map) {
    return UserEssence(
      id: map['id'] as String,
      account: map['account'] as String,
      password: map['password'] as String,
      username: map['username'] as String,
      signature: map['signature'] as String,
      avatar: map['avatar'] as String,
    );
  }

  /// 转换为Map
  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'account': account,
      'password': password,
      'username': username,
      'signature': signature,
      'avatar': avatar,
    };
  }

  /// 复制并更新部分字段
  UserEssence copyWith({
    String? id,
    String? account,
    String? password,
    String? username,
    String? signature,
    String? avatar,
  }) {
    return UserEssence(
      id: id ?? this.id,
      account: account ?? this.account,
      password: password ?? this.password,
      username: username ?? this.username,
      signature: signature ?? this.signature,
      avatar: avatar ?? this.avatar,
    );
  }
}
